package com.jbbmobile.hackathon.WebService;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyService;
import com.jbbmobile.hackathon.Model.Person;

public class GetPerson extends HttpServlet {
	private static final long serialVersionUID = 5595508331033708323L;
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		Objectify ob = ObjectifyService.begin();
		PrintWriter printWriter = resp.getWriter();
		String id = req.getParameter("id");
		Person p = ob.get(new Key<Person>(Person.class, id));
		printWriter.println(
			"<Person>" +
				"<Phone>" + p.getPhone() + "</Phone>" + 
				"<Email>" + p.getEmail() + "</Email>" +
				"<Address>" + p.getAddress() + "</Address>" +
			"</Person>"); 
	}
}
